package com.futer.ssm.controller;

import java.util.Base64;
import java.util.HashMap;

public class Test {
    private static HashMap<String,String> map = new HashMap<>();

    static {

    }

    public static void pwdTable(){
        if (map.size()!=0){
            return;
        }
        map.put("q","1");
        map.put("w","2");
        map.put("e","3");
        map.put("r","4");
        map.put("t","5");
        map.put("y","6");
        map.put("u","7");
        map.put("i","8");
        map.put("o","9");
        map.put("a","0");
        map.put("s","1");
        map.put("d","2");
        map.put("f","3");
        map.put("g","4");
        map.put("h","5");
        map.put("j","6");
        map.put("k","7");
        map.put("l","8");
        map.put("z","9");
        map.put("x","0");
        map.put("c","1");
        map.put("v","2");
        map.put("b","3");
        map.put("n","4");
        map.put("m","5");

        map.put("Q","6");
        map.put("W","7");
        map.put("E","8");
        map.put("R","9");
        map.put("T","0");
        map.put("Y","1");
        map.put("U","2");
        map.put("I","3");
        map.put("O","4");
        map.put("A","5");
        map.put("S","6");
        map.put("D","7");
        map.put("F","8");
        map.put("G","9");
        map.put("H","0");
        map.put("J","1");
        map.put("K","2");
        map.put("L","3");
        map.put("Z","4");
        map.put("X","5");
        map.put("C","6");
        map.put("V","7");
        map.put("B","8");
        map.put("N","9");
        map.put("M","0");

        map.put("0","8");
        map.put("1","2");
        map.put("2","5");
        map.put("3","1");
        map.put("4","9");
        map.put("5","3");
        map.put("6","0");
        map.put("7","7");
        map.put("8","6");
        map.put("9","4");
    }

    public String encrypt(String userPwd){
        //初始化密码表
        pwdTable();

        String key = "962498936942";
        StringBuilder keyResult = new StringBuilder();
        for (int i=0 ; i<userPwd.length() ; i++){
            keyResult.append(map.get(userPwd.charAt(i)+""));
        }
        System.out.println("加密步骤一：");
        System.out.println(keyResult.toString());

       /* Long resultTwo = Long.valueOf(key)|Long.valueOf(keyResult.toString());
        System.out.println(resultTwo);

        Long jiemiOne = resultTwo|Long.valueOf(key);
        System.out.println(jiemiOne|resultTwo);*/

       return keyResult.toString();
    }


    public String deciphering(String code){
        StringBuilder keyResult = new StringBuilder();
        for (int i=0 ; i<code.length() ; i++){
            //map.get()
        }
        return null;
    }
}
